const CourseObj = require('../modules/Course');

let CourseController = {

    //添加课程
    post_addCourse: async function(req, res) {
        let coursename = '',
            typename = '';
        if (req.body.courseVal) {
            coursename = req.body.courseVal;
        }
        if (req.body.typeVal) {
            typename = req.body.typeVal;
        }
        await CourseObj.add_course(coursename, typename);
        res.send({
            code: 200,
            msg: '添加成功'
        })
    },

    //删除课程
    post_delete: async function(req, res) {
        let course = '';
        if (req.body.course) {
            course = req.body.course;
        }
        course = course.trim();
        await CourseObj.delete_course(course);
        res.send({
            'code': 200,
            'msg': '删除成功'
        })
    }
}

module.exports = CourseController;